package com.atguigu01.create.runnable;

/**
 * ClassName: PersonTest
 * Description:
 *
 * @Author liu
 * @Create 2024/11/14 23:25
 * @Version 1.0
 */

//实现接口Runnable
    class EvenNumber implements Runnable{

    @Override
    public void run() {

        for(int i = 1;i <= 100;i++){
            System.out.println(Thread.currentThread().getName() + ":" + i);
        }
    }
}
public class EvenNumberTest {
    public static void main(String[] args) {
        EvenNumber p = new EvenNumber();

        Thread t1 = new Thread(p);
        t1.start();

        Thread t2 = new Thread(p);
        t2.start();

        //或
        new Thread(new Runnable() {
            @Override
            public void run() {

                for(int i = 1;i <= 100;i++){
                    System.out.println(Thread.currentThread().getName() + ":" + i);
                }
            }
        }).start();
    }

}
